<?php
 $fenetre = 1 ;
 If (!IsSet ($reentrance))
  {
   Session_Start () ;
   If (!$_SESSION ["repertoire_config"]) { Header ("Location: ../../") ; }
   Include ("../../include/garennes.cfg") ;
   Include ("../../include/init.php") ;
   Include ("../include/config.inc") ;
   verif_droits ($droit_courant, $_SESSION ["code"]) ;
  }
 
 $id_classe = var_courante ("id_classe", 0, null) ;
 $c = var_courante ("c", 0, null) ;
 $action = var_courante ("action", 0, 1) ;
 $jour = var_courante ("jour", 0, Date ("j")) ;
 $mois = var_courante ("mois", 0, Date ("m")) ;
 $annee = var_courante ("annee", 0, Date ("Y")) ;
 $coefficient = var_courante ("coefficient", 0, 0) ;
 $max = var_courante ("max", 0, 20) ;
 $sous_matiere = var_courante ("sous_matiere", 0, 0) ;
 $examen = var_courante ("examen", 0, 0) ;
 $valeur = var_courante ("valeur", 0, "-") ;
 $description = var_courante ("description", 0, "") ;
 $submit = var_courante ("submit", 0, "") ;
 $menu = var_courante ("menu", 0, 0) ;
 $code = var_courante ("code", 0, $_SESSION ["code"]) ;
 $exam = var_courante ("exam", 0, 0) ;
 $id_classe = var_courante ("id_classe", 0, 0) ;
 $discipline = var_courante ("discipline", 0, 0) ;
 $professeur = var_courante ("professeur", 0, 0) ;
 $id_service_prof = var_courante ("id_service_prof", 0, 0) ;
 $id_service_classe = var_courante ("id_service_classe", 0, 0) ;
 $periode = var_courante ("periode", 0, 0) ;
 $millesime = millesime (0) ;
 
 $type_discipline = champ_disc_type_discipline_parid ($discipline) ;
 $type_moyenne = champ_disc_type_moyenne_parid ($discipline) ;
 
 $param_theme = parametres_theme (themeparsession ($_SESSION ["code"])) ;
 $rep_themes = "../../images/themes/" ;
 Include ($rep_themes.$param_theme ["nom_repertoire"]."/".$param_theme ["fichier_config"]) ;
 
 If ($droit_courant != $droit_prof)
  {
   $resultats = SQL_commande ("SELECT * FROM menus WHERE numero='".$droit_courant."' AND ordre='0'", $id_sql) ;
   $l = SQL_tableau_associatif ($resultats, "") ; 
  }
 
 If (IsSet ($c))
  { 
   $resultat_controle = SQL_commande ("SELECT * FROM controles WHERE id_controle='".$c."' LIMIT 1", $id_sql) ;
   If (SQL_nbr_lignes ($resultat_controle) > 0) { $controle = SQL_tableau_associatif ($resultat_controle, "") ; }
  }

 If (IsSet ($id_classe))
  {
   $rens_cl = SQL_commande ("SELECT examen FROM classes WHERE id_classe='".$id_classe."' LIMIT 1", $id_sql) ;
   $rcl = SQL_ligne_suivante ($rens_cl) ;
   $exam = $rcl [0] ;
   
   Switch ($action)
    {
     Case 1 : // -------------------------------------------------------------------------------------------------------
              // Modification des parametres
              $resultat = SQL_commande ("SELECT * FROM sessions WHERE id_session='".$_SESSION ["code"]."' LIMIT 1", $id_sql) ;
              $param = SQL_tableau_associatif ($resultat, "") ;
	      $t = Explode (" ", $param ["date"]) ;
	      $t = Explode ("-", $t [0]) ;
	      
	      Echo "<HTML><HEAD>" ;
              entete_html ("Garennes", "", 1) ;
              Echo styles ("none", "none", "none", $theme [0][32], "none") ;
	      If ($exam > 0)
	       {
	        Echo "<SCRIPT>\n" ;
	        Echo "var exam1='" ; If ($param ["examen"] > 0) { Echo $param ["examen"]."'\n" ; } Else { Echo "1,00'\n" ; }
	        Echo "var exam2=''\n" ;
	        Echo "function active_exam()\n" ;
	        Echo "{\n" ;
	        Echo "document.param.valeur.disabled=0\n" ;
	        Echo "document.param.valeur.readonly=0\n" ;
	        Echo "if (exam2!='') { document.param.valeur.value=exam2 }\n" ;
	        Echo "else { document.param.valeur.value=exam1 }\n" ;
	        Echo "document.param.valeur.focus()\n" ;
	        Echo "}\n" ;
	        Echo "function desactive_exam()\n" ;
	        Echo "{\n" ;
	        Echo "if (document.param.valeur.disabled==0)\n" ;
	        Echo "{\n" ;
	        Echo "if (document.param.valeur.value!=exam1 && document.param.valeur.value!='')\n" ;
	        Echo "{\n" ;
	        Echo "exam2=document.param.valeur.value\n" ;
	        Echo "document.param.valeur.value=exam2\n" ;
	        Echo "}\n" ;
	        Echo "else { document.param.valeur.value=exam1 }\n" ;
	        Echo "document.param.valeur.disabled=1\n" ;
	        Echo "document.param.valeur.readonly=1\n" ;
	        Echo "}\n" ;
	        Echo "}\n" ;
	        Echo "function modif_exam()\n" ;
	        Echo "{\n" ;
	        Echo "if (document.param.examen.checked==1) { active_exam() }\n" ;
	        Echo "else { desactive_exam() }\n" ;
	        Echo "}\n" ;
	        Echo "</SCRIPT>" ;
               }
              Echo "</HEAD>" ;
	      Echo "<BODY BACKGROUND=\"".$rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][10]."\" TEXT=\"".$l ["couleur_texte"]."\" onContextMenu=\"return false\">" ;
	      //Echo "<CENTER><FONT COLOR=\"".$theme [0][38]."\">Param&egrave;tres&nbsp;nouvelle&nbsp;colonne&nbsp;de&nbsp;notes.</FONT></CENTER>" ;
	      Echo "<FORM ACTION=\"./saisie_parametres.php\" METHOD=\"POST\" NAME=\"param\">" ;
	      
              $non_centrer = 0 ;
	      $titre_fenetre = "Saisie&nbsp;des&nbsp;param&egrave;tres&nbsp;de&nbsp;la&nbsp;nouvelle&nbsp;colonne&nbsp;de&nbsp;notes" ;
	      $taille_longueur_max = 0 ;
	    
	      //If ($droit_courant == $droit_prof) { Include ("../include/debut_theme.inc") ; }
	      //Else { Echo "<CENTER><FONT SIZE=\"+1\" COLOR=\"#0000FF\">".$titre_fenetre."</FONT></CENTER>" ; }
	      Include ("../include/debut_theme.inc") ;
  
	      Echo "<TABLE BORDER=\"0\" BGCOLOR=\"" ;
	      //If ($droit_courant != $droit_prof) { Echo $l ["couleur_fond"] ; } Else { Echo $theme [0][3] ; }
	      Echo $theme [0][3] ;
	      Echo "\" WIDTH=\"100%\">" ;
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"RIGHT\">&nbsp;Date&nbsp;de&nbsp;la&nbsp;nouvelle&nbsp;colonne&nbsp;:&nbsp;</TD>" ;
              Echo "<TD>".saisie_date ($t [2], $t [1], $t [0], Date ("Y")-1, 3, "jour", "mois", "annee")."</TD>" ; 
	      Echo "</TR>" ;
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"RIGHT\">&nbsp;C&oelig;fficient&nbsp;de&nbsp;la&nbsp;nouvelle&nbsp;colonne&nbsp;:&nbsp;</TD>" ;
	      Echo "<TD><INPUT TYPE=\"TEXT\" NAME=\"coefficient\" SIZE=\"5\" MAXLENGTH=\"10\" VALUE=\"".Str_Replace ('.', ',', $param ["coefficient"])."\"></TD>" ;
	      Echo "</TR>" ;
	      If ($type_moyenne == 0)
	       {
	        If ($param ["max"] <= 0)
	         {
	          If ($note_par_defaut  <= 0) { $param ["max"] = 20 ; } Else { $param ["max"] = $note_par_defaut ; }
                 }
	        Echo "<TR>" ;
	        Echo "<TD ALIGN=\"RIGHT\">&nbsp;Notes&nbsp;sur&nbsp;</TD>" ;
	        Echo "<TD><INPUT TYPE=\"TEXT\" NAME=\"max\" SIZE=\"5\" VALUE=\"".Str_Replace ('.', ',', $param ["max"])."\"></TD>" ;
	        Echo "</TR>" ;
	       }
	      ElseIf ($type_moyenne == 1)
	       {
	        Echo "<tr>" ;
	        Echo "<td align=\"right\">&nbsp;Notes&nbsp;sur&nbsp;</td>" ;
	        Echo "<td>100&nbsp;(Pourcentage).<input type=\"hidden\" name=\"max\" value=\"100\"></td>" ;
	        Echo "</tr>" ;
	       }
	    
	      // Sous matiere
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"RIGHT\">Sous-mati&egrave;re&nbsp;:&nbsp;</TD>" ;
	      Echo "<TD><SELECT NAME=\"sous_matiere\"><OPTION VALUE=\"0\"></OPTION>"  ;
	      $smat = SQL_commande ("SELECT * FROM sous_matieres WHERE millesime='".$millesime."' ORDER BY nom", $id_sql) ;
	      For ($i = 0 ; $i < SQL_nbr_lignes ($smat) ; $i++)
	       {
	        $sous_mat = SQL_tableau_associatif ($smat, "") ;
                If (($i > 0) And ($sous_mat ["nom"] != $sous_mat_old))
                 {
		  Echo "<option value=\"".$sous_mat ["id_sous_matiere"]."\"" ; If ($param ["sous_matiere"] == $sous_mat ["id_sous_matiere"]) { Echo " selected" ; }
		  Echo ">".$sous_mat ["nom"]."</option>" ; }
                $sous_mat_old = $sous_mat ["nom"] ;
	       }
	      Echo "</SELECT></TD>" ;
	      Echo "</TR>" ;
	      
	      If (($exam > 0) And ($type_discipline == 0))
	       {
	        Echo "<TR>" ;
	        Echo "<TD ALIGN=\"RIGHT\" vALIGN=\"TOP\"><INPUT TYPE=\"CHECKBOX\" NAME=\"examen\" VALUE=\"1\"" ;
	        If ($param ["examen"] > 0) { Echo " CHECKED" ; }
	        Echo " onClick=\"javascript:modif_exam()\"></TD>" ;
	        Echo "<TD>Examen&nbsp;blanc</TD>" ;
	        Echo "</TR>" ;
	        
	        Echo "<TR>" ;
	        Echo "<TD></TD>" ;
	        Echo "<TD>Coeff.&nbsp;examen&nbsp;blanc&nbsp;:&nbsp;<INPUT TYPE=\"TEXT\" NAME=\"valeur\" VALUE=\""  ;
                If ($param ["examen"] > 0) { Echo Str_Replace ('.', ',', $param ["examen"]) ; } Else { Echo "1,00" ; }
	        Echo "\" SIZE=\"5\" MAXLENGTH=\"10\"" ;
	        If ($param ["examen"] == 0) { Echo " DISABLED" ; }
	        Echo "></TD>" ;
	        Echo "</TR>" ;
               }
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"RIGHT\" valign=\"top\">&nbsp;Commentaire&nbsp;pour&nbsp;la&nbsp;nouvelle&nbsp;colonne&nbsp;:&nbsp;</TD>" ;
	      Echo "<TD><TEXTAREA NAME=\"description\" ROWS=\"2\" COLS=\"24\">".$param ["description"]."</TEXTAREA></TD>" ;
	      Echo "</TR>" ;
	      Echo "<TR><TD COLSPAN=\"2\"></TD></TR>" ;
	      Echo "<TR>" ;
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"CENTER\"><A HREF=\"javascript:window.close()\"><IMG SRC=\"" ;
	      //If ($droit_courant != $droit_prof) { Echo "../images/annuler.png" ; }
	      //Else { Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][3] ; }
	      Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][3] ;
	      Echo "\" BORDER=\"0\"></A></TD>" ;
	      Echo "<TD ALIGN=\"CENTER\">" ;
	      Echo "<INPUT TYPE=\"IMAGE\" SRC=\"" ;
	      //If ($droit_courant != $droit_prof) { Echo "../images/valider.png" ; }
	      //Else { Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][0] ; }
	      Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][0] ;
	      Echo "\" NAME=\"submit\" VALUE=\" Valider \" BORDER=\"0\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"menu\" VALUE=\"".$menu."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"2\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"code\" VALUE=\"".$_SESSION ["code"]."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"exam\" VALUE=\"".$exam."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_classe\" VALUE=\"".$id_classe."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"discipline\" VALUE=\"".$discipline."\">" ;
	      Echo "</TD>" ;
	      Echo "</TR>" ;
	      Echo "</TABLE>" ;
	    
	      //If ($droit_courant == $droit_prof) { Include ("../include/fin_theme.inc") ; }
	      Include ("../include/fin_theme.inc") ;
	      
	      Echo "</FORM>" ;
	      Echo "</BODY>" ;
	      Echo "</HTML>" ;
              Break ;
     Case 2 : $coefficient = Str_Replace (',', '.', $coefficient) ;
              If ($coefficient < 0) { $coefficient = -$coefficient ; }
              $max = Str_Replace (',', '.', $max) ;
	      If ($max < 0) { $max = -$max ; }
	      ElseIf ($max == 0) { $max = $note_par_defaut ; }
	      If ($max <= 0)
	       {
	        //$gestion = SQL_commande ("SELECT max FROM gestion LIMIT 1", $id_sql) ;
	        $gestion = SQL_commande ("SELECT max FROM etablissements e,classes c WHERE c.id_classe='".$id_classe."' AND c.etablissement=e.id_etablissement LIMIT 1", $id_sql) ;
	        $g = SQL_ligne_suivante ($gestion) ;
	        If ($g [0] <= 0) { $max = 20 ; } Else { $max = $g [0] ; }
	       }
              $date = $annee."-".$mois."-".$jour ;
	      If ($exam > 0)
	       {
	        If ($examen == 1) { $exam_valeur = Str_Replace (',', '.', $valeur) ; } Else { $exam_valeur = 0 ; }
	        If ($exam_valeur < 0) { $exam_valeur = -$exam_valeur ; }
               }
              Else { $exam_valeur = 0 ; }
              If ($sous_matiere < 1) { $sous_matiere = 0 ; }
              $resultat = SQL_commande ("UPDATE sessions SET date='".$date."',description='".$description."',coefficient='".$coefficient."',examen='".$exam_valeur."',max='".$max."',sous_matiere='".$sous_matiere."'
	  			          WHERE id_session='".$_SESSION ["code"]."' LIMIT 1", $id_sql) ;
              Echo "<HTML><HEAD><SCRIPT> window.close() ; </SCRIPT></HEAD></HTML>" ;
              Break ;
     Case 3 : $resultat = SQL_commande ("SELECT * FROM sessions WHERE id_session='".$_SESSION ["code"]."' LIMIT 1", $id_sql) ;
              $param = SQL_tableau_associatif ($resultat, "") ;
	      $t = Explode (" ", $param ["date"]) ;
	      $t = Explode ("-", $t [0]) ;
	      
	      Echo "<HTML><HEAD>" ;
	      entete_html ("Garennes", "", 1) ;
              Echo styles ("none", "none", "none", $theme [0][32], "none") ;
	      Echo "<SCRIPT>" ;
	      Echo "var exam1='" ; If ($controle ["examen"] > 0) { Echo $controle ["examen"]."';" ; } Else { Echo "1,00';" ; }
	      Echo "var exam2='';" ;
	      Echo "function active_exam(){" ;
	      Echo "document.param.valeur.disabled=0;" ;
	      Echo "document.param.valeur.readonly=0;" ;
	      Echo "if (exam2!=''){document.param.valeur.value=exam2}else{document.param.valeur.value=exam1}" ;
	      Echo "document.param.valeur.focus()}" ;
	      Echo "function desactive_exam(){" ;
	      Echo "if (document.param.valeur.disabled==0){" ;
	      Echo "if (document.param.valeur.value!=exam1 && document.param.valeur.value!=''){" ;
	      Echo "exam2=document.param.valeur.value;" ;
	      Echo "document.param.valeur.value=exam2;}" ;
	      Echo "else{document.param.valeur.value=exam1}" ;
	      Echo "document.param.valeur.disabled=1;" ;
	      Echo "document.param.valeur.readonly=1;}}" ;
	      Echo "function modif_exam(){if (document.param.examen.checked==1){active_exam()}else{desactive_exam()}}" ;
	      Echo "</SCRIPT></HEAD>" ;
	      Echo "<BODY BACKGROUND=\"".$rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][10]."\" TEXT=\"".$ligne ["couleur_texte"]."\" onContextMenu=\"return false\">" ;
	      Echo "<FORM ACTION=\"./saisie_parametres.php\" METHOD=\"POST\" NAME=\"param\">" ;
	    
	      $titre_fenetre = "Sous-mati&egrave;re&nbsp;et&nbsp;coefficient&nbsp;examen&nbsp;blanc." ;
	      $taille_longueur_max = 0 ;
	    
	      //If ($droit_courant == $droit_prof) { Include ("../include/debut_theme.inc") ; }
	      //Else { Echo "<CENTER><FONT SIZE=\"+1\" COLOR=\"#0000FF\">".$titre_fenetre."</FONT></CENTER>" ; }
	      Include ("../include/debut_theme.inc") ;
  
  	      Echo "<TABLE BORDER=\"0\" BGCOLOR=\"" ;
	      //If ($droit_courant != $droit_prof) { Echo $l ["couleur_fond"] ; } Else { Echo $theme [0][3] ; }
	      Echo $theme [0][3] ;
	      Echo "\" WIDTH=\"100%\">" ;
	      
	      Echo "<TR>" ;
	      Echo "<TD>Sous-mati&egrave;re&nbsp;:&nbsp;</TD>" ;
	      Echo "<TD><SELECT NAME=\"sous_matiere\"><OPTION VALUE=\"0\"></OPTION>"  ;
	      $sdisc = SQL_commande ("SELECT * FROM sous_matieres WHERE millesime='".$millesime."' ORDER BY nom", $id_sql) ;
	      For ($i = 0 ; $i < SQL_nbr_lignes ($sdisc) ; $i++)
	       {
	        $sous_disc = SQL_tableau_associatif ($sdisc, "") ;
	        Echo "<OPTION VALUE=\"".$sous_disc ["id_sous_matiere"]."\"" ;
	        If (($controle ["sous_matiere"] > 0) And ($controle ["sous_matiere"] == $sous_disc ["id_sous_matiere"])) { Echo " SELECTED" ; }
	        Echo ">".$sous_disc ["nom"]."</OPTION>" ;
	       }
	      Echo "</SELECT></TD>" ;
	      Echo "</TR>" ;
	      
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"RIGHT\"><INPUT TYPE=\"CHECKBOX\" NAME=\"examen\" VALUE=\"1\" onClick=\"javascript:modif_exam()\"" ;
	      If ($controle ["examen"] > 0) { Echo " CHECKED" ; }
	      Echo "></TD>" ;
	      Echo "<TD>Examen&nbsp;blanc</TD>" ;
	      Echo "</TR>" ;
	      Echo "<TR>" ;
	      Echo "<TD></TD>" ;
	      Echo "<TD>Coeff.&nbsp;examen&nbsp;blanc&nbsp;:&nbsp;<INPUT TYPE=\"TEXT\" NAME=\"valeur\" VALUE=\"" ;
	      If ($controle ["examen"] > 0) { Echo Str_Replace (".", ",", $controle ["examen"])."\"" ; } Else { Echo "1,00\" DISABLED" ; }
	      Echo " SIZE=\"5\" MAXLENGTH=\"10\"></TD>" ;
	      Echo "</TR>" ;
	      
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"CENTER\"><A HREF=\"javascript:window.close()\"><IMG SRC=\"" ;
	      If ($droit_courant != $droit_prof) { Echo "../images/annuler.png" ; }
	      Else { Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][3] ; }
	      Echo "\" BORDER=\"0\"></A></TD>" ;
	      Echo "<TD ALIGN=\"CENTER\">" ;
	      Echo "<INPUT TYPE=\"IMAGE\" SRC=\"" ;
	      If ($droit_courant != $droit_prof) { Echo "../images/valider.png" ; }
	      Else { Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][0] ; }
	      Echo "\" NAME=\"submit\" VALUE=\" Valider \" BORDER=\"0\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"menu\" VALUE=\"".$menu."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"4\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"code\" VALUE=\"".$_SESSION ["code"]."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_classe\" VALUE=\"".$id_classe."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"professeur\" VALUE=\"".$professeur."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_service_prof\" VALUE=\"".$id_service_prof."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_service_classe\" VALUE=\"".$id_service_classe."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"periode\" VALUE=\"".$periode."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"c\" VALUE=\"".$c."\">" ;
	      Echo "</TD>" ;
	      Echo "</TR>" ;
	      Echo "</TABLE>" ;
	      
	      //If ($droit_courant == $droit_prof) { Include ("../include/fin_theme.inc") ; }
	      Include ("../include/fin_theme.inc") ;
	    
	      Echo "</FORM>" ;
	      Echo "</BODY></HTML>" ;
              Break ;
     Case 4 : If ($examen == 1) { $exam_valeur = Str_Replace (',', '.', $valeur) ; } Else { $exam_valeur = 0 ; }
	      If ($exam_valeur < 0) { $exam_valeur = -$exam_valeur ; }
	      If ($sous_matiere < 1) { $sous_matiere = 0 ; }
              $resultat = SQL_commande ("UPDATE controles SET examen='".$exam_valeur."',sous_matiere='".$sous_matiere."' WHERE id_controle='".$c."' LIMIT 1", $id_sql) ;
	      $resultat = SQL_commande ("UPDATE calcul_moyenne SET ok='0'
                                          WHERE classe='".$id_classe."' AND periode='".$periode."'
		                            AND service_prof='".$id_service_prof."' AND service_classe='".$id_service_classe."'
                                          LIMIT 1", $id_sql) ;
	      Echo "<HTML><HEAD><SCRIPT> window.open(\"./saisie_notes.php?code=".$_SESSION ["code"]."&id_classe=".$id_classe."&professeur=".$professeur."&id_service_prof=".$id_service_prof."&periode=".$periode ;
	      If ($droit_courant != $droit_prof) { Echo "&menu=200\",\"travail_affichage_3" ; } Else { Echo "\",\"travail_affichage" ; }
	      Echo "\",\"\");" ;
	      Echo " window.close(); </SCRIPT></HEAD></HTML>" ;
              Break ;
     Case 5 : $resultat = SQL_commande ("SELECT * FROM sessions WHERE id_session='".$_SESSION ["code"]."' LIMIT 1", $id_sql) ;
              $param = SQL_tableau_associatif ($resultat, "") ;
	      $t = Explode (" ", $param ["date"]) ;
	      $t = Explode ("-", $t [0]) ;
	      
	      Echo "<HTML><HEAD>" ;
	      entete_html ("Garennes", "", 1) ;
              Echo styles ("none", "none", "none", $theme [0][32], "none") ;
	      Echo "<SCRIPT>" ;
	      Echo "var exam1='" ; If ($controle ["examen"] > 0) { Echo $controle ["examen"]."';" ; } Else { Echo "1,00';" ; }
	      Echo "var exam2='';" ;
	      Echo "function active_exam(){" ;
	      Echo "document.param.valeur.disabled=0;" ;
	      Echo "document.param.valeur.readonly=0;" ;
	      Echo "if (exam2!=''){document.param.valeur.value=exam2}" ;
	      Echo "else{document.param.valeur.value=exam1}" ;
	      Echo "document.param.valeur.focus()}" ;
	      Echo "function desactive_exam(){" ;
	      Echo "if (document.param.valeur.disabled==0){" ;
	      Echo "if (document.param.valeur.value!=exam1 && document.param.valeur.value!=''){" ;
	      Echo "exam2=document.param.valeur.value;" ;
	      Echo "document.param.valeur.value=exam2;" ;
	      Echo "}else{document.param.valeur.value=exam1}" ;
	      Echo "document.param.valeur.disabled=1;" ;
	      Echo "document.param.valeur.readonly=1;" ;
	      Echo "}}" ;
	      Echo "function modif_exam(){" ;
	      Echo "if (document.param.examen.checked==1){active_exam()}" ;
	      Echo "else{desactive_exam()}}" ;
	      Echo "</SCRIPT></HEAD>" ;
	      Echo "<BODY BACKGROUND=\"".$rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][10]."\" TEXT=\"".$ligne ["couleur_texte"]."\" onContextMenu=\"return false\">" ;
	      Echo "<FORM ACTION=\"./saisie_parametres.php\" METHOD=\"POST\" NAME=\"param\">" ;
	    
	      $titre_fenetre = "Sous-mati&egrave;re&nbsp;et&nbsp;coefficient&nbsp;examen&nbsp;blanc." ;
	      $taille_longueur_max = 0 ;
	    
	      //If ($droit_courant == $droit_prof) { Include ("../include/debut_theme.inc") ; }
	      //Else { Echo "<CENTER><FONT SIZE=\"+1\" COLOR=\"#0000FF\">".$titre_fenetre."</FONT></CENTER>" ; }
  	      Include ("../include/debut_theme.inc") ;
  
	      Echo "<TABLE BORDER=\"0\" BGCOLOR=\"" ;
	      //If ($droit_courant != $droit_prof) { Echo $l ["couleur_fond"] ; } Else { Echo $theme [0][3] ; }
	      Echo $theme [0][3] ;
	      Echo "\" WIDTH=\"100%\">" ;
	      
	      Echo "<TR>" ;
	      Echo "<TD>Sous-mati&egrave;re&nbsp;:&nbsp;</TD>" ;
	      Echo "<TD><SELECT NAME=\"sous_matiere\"><OPTION VALUE=\"0\"></OPTION>"  ;
	      $sdisc = SQL_commande ("SELECT * FROM sous_matieres WHERE millesime='".$millesime."' ORDER BY nom", $id_sql) ;
	      For ($i = 0 ; $i < SQL_nbr_lignes ($sdisc) ; $i++)
	       {
	        $sous_disc = SQL_tableau_associatif ($sdisc, "") ;
	        Echo "<OPTION VALUE=\"".$sous_disc ["id_sous_matiere"]."\"" ;
	        If (($controle ["sous_matiere"] > 0) And ($controle ["sous_matiere"] == $sous_disc ["id_sous_matiere"])) { Echo " SELECTED" ; }
	        Echo ">".$sous_disc ["nom"]."</OPTION>" ;
	       }
	      Echo "</SELECT></TD>" ;
	      Echo "</TR>" ;
	      
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"RIGHT\"><INPUT TYPE=\"CHECKBOX\" NAME=\"examen\" VALUE=\"1\" onClick=\"javascript:modif_exam()\"" ;
	      If ($controle ["examen"] > 0) { Echo " CHECKED" ; }
	      Echo "></TD>" ;
	      Echo "<TD>Examen&nbsp;blanc</TD>" ;
	      Echo "</TR>" ;
	      Echo "<TR>" ;
	      Echo "<TD></TD>" ;
	      Echo "<TD>Coeff.&nbsp;examen&nbsp;blanc&nbsp;:&nbsp;<INPUT TYPE=\"TEXT\" NAME=\"valeur\" VALUE=\"" ;
	      If ($controle ["examen"] > 0) { Echo Str_Replace (".", ",", $controle ["examen"])."\"" ; } Else { Echo "1,00\" DISABLED" ; }
	      Echo " SIZE=\"5\" MAXLENGTH=\"10\"></TD>" ;
	      Echo "</TR>" ;
	      
	      Echo "<TR>" ;
	      Echo "<TD ALIGN=\"CENTER\"><A HREF=\"javascript:window.close()\"><IMG SRC=\"" ;
	      If ($droit_courant != $droit_prof) { Echo "../images/annuler.png" ; }
	      Else { Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][3] ; }
	      Echo "\" BORDER=\"0\"></A></TD>" ;
	      Echo "<TD ALIGN=\"CENTER\">" ;
	      Echo "<INPUT TYPE=\"IMAGE\" SRC=\"" ;
	      If ($droit_courant != $droit_prof) { Echo "../images/valider.png" ; }
	      Else { Echo $rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][0] ; }
	      Echo "\" NAME=\"submit\" VALUE=\" Valider \" BORDER=\"0\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"menu\" VALUE=\"".$menu."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"6\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"code\" VALUE=\"".$_SESSION ["code"]."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_classe\" VALUE=\"".$id_classe."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"professeur\" VALUE=\"".$professeur."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_service_prof\" VALUE=\"".$id_service_prof."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_service_classe\" VALUE=\"".$id_service_classe."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"periode\" VALUE=\"".$periode."\">" ;
	      Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"c\" VALUE=\"".$c."\">" ;
	      Echo "</TD>" ;
	      Echo "</TR>" ;
	      Echo "</TABLE>" ;
	      
	      //If ($droit_courant == $droit_prof) { Include ("../include/fin_theme.inc") ; }
	      Include ("../include/fin_theme.inc") ;
	      
	      Echo "</FORM>" ;
	      Echo "</BODY></HTML>" ;
              Break ;
     Case 6 : If ($examen == 1) { $exam_valeur = Str_Replace (',', '.', $valeur) ; } Else { $exam_valeur = 0 ; }
	      If ($exam_valeur < 0) { $exam_valeur = -$exam_valeur ; }
	      If ($sous_matiere < 1) { $sous_matiere = 0 ; }
              $resultat = SQL_commande ("UPDATE controles SET examen='".$exam_valeur."',sous_matiere='".$sous_matiere."' WHERE id_controle='".$c."' LIMIT 1", $id_sql) ;
	      $resultat = SQL_commande ("UPDATE calcul_moyenne SET ok='0'
                                          WHERE classe='".$id_classe."' AND periode='".$periode."'
	  	                          AND service_prof='".$id_service_prof."' AND service_classe='".$id_service_classe."'
                                          LIMIT 1", $id_sql) ;
	      Echo "<html><head><script type=\"text/javascript\">window.open(\"./saisie_notes.php?code=".$_SESSION ["code"]."&id_classe=".$id_classe."&professeur=".$professeur."&id_service_prof=".$id_service_prof."&periode=".$periode ;
	      If ($droit_courant != $droit_prof) { Echo "&menu=200\",\"travail_affichage_3" ; } Else { Echo "\",\"travail_affichage" ; }
	      Echo "\",\"\");window.close();</script></head></html>" ;
              Break ;
    }
  }
 Else
  {
   Echo "<HTML><HEAD>" ;
   entete_html ("Garennes", "", 1) ;
   Echo styles ("none", "none", "none", $theme [0][32], "none") ;
   Echo "</HEAD>" ;
   Echo "<BODY BACKGROUND=\"".$rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][10]."\" TEXT=\"".$ligne ["couleur_texte"]."\" onContextMenu=\"return false\">" ;
   Echo "<br>Il y aun probl&grave;me d'acc&egrave;s aux param&eacute;trage de la saisie de notes !<br>Contactez votre administrateur Garennes." ;
   Echo "</body></html>" ;
  }
?>